{include file="public/head"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">{if $info}编辑{else /}添加{/if}退款原因</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" wid100 lay-filter="form">

                        <div class="layui-form-item">
                            <label class="layui-form-label">退款原因</label>
                            <div class="layui-input-inline">
                                <input type="text" lay-verify="required" name="title" maxlength="20" placeholder="请输入退款原因" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" value="1" title="显示">
                                <input type="radio" name="status" value="0" title="隐藏">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline">
                                <input type="number" name="sort" placeholder="排序" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">排序越大显示越靠前</div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                {if $info}
                                <input type="hidden" name="id" value="{$info.id}">
                                {/if}
                                <button class="layui-btn" lay-submit lay-filter="{if $info}edit-btn{else /}add-btn{/if}">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYADMIN__/',
        version: 20220407
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','upload','form'],function(){

        var $=layui.$,admin = layui.admin,form = layui.form,upload=layui.upload;
        form.val("form", {$info|raw});


        //编辑提交
        form.on('submit(edit-btn)', function (data) {
            admin.req({
                url: '{:url(\'OrderReason/edit\')}' //实际使用请改成服务端真实接口
                , type: 'post'
                , data: data.field
                , done: function (res) {
                    layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                        parent.layer.closeAll("iframe");
                        //刷新父页面
                        parent.tableIn.reload();
                    });
                }
            });
        });

        //添加提交
        form.on('submit(add-btn)', function (data) {
            admin.req({
                url: '{:url(\'OrderReason/add\')}' //实际使用请改成服务端真实接口
                , type: 'post'
                , data: data.field
                , done: function (res) {
                    layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                        parent.layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    });
                }
            });
        });

    });
</script>
</body>
</html>